package Day08;

import jdk.swing.interop.SwingInterOpUtils;

import java.util.Scanner;

public class StringBuilderDemo3 {
    public static void main(String[] args) {
        /*//1创建对象
        StringBuilder sb = new StringBuilder("abcd");
        sb.append("dffdfdbiuekh");
        sb.append("advh");
        sb.reverse();
        String result = sb.toString();
        int len = sb.length();
        System.out.println(len);

        System.out.println(result);
        //System.out.println(sb);*/

        /*Scanner sc = new Scanner(System.in);
        System.out.println("求你输入一个字符串吧，少爷");
        String name = sc.next();

        String result = new StringBuilder().append(name).reverse().toString();

        if(name.equals(result)){
            System.out.println("这个是一个对称字符串");
        }else{
            System.out.println("这个不是一个反转字符串");
        }*/
        int[] arr = {1,2,3};
        String str = arrToString(arr);
        System.out.println(str);

    }

    public static String arrToString(int[] arr){
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (int i = 0; i < arr.length; i++) {
            if(i == arr.length - 1){
                sb.append(arr[i]);
            }else{
                sb.append(arr[i]).append(" ,");
            }
        }
        sb.append("]");
        return sb.toString();
    }
}
